// todate默认参数是当前日期，可以传入对应时间 todate格式为2018-10-05
function formatDate(todate) {
	var dateArry = dateLater(todate);
	return dateArry;
}

function dateLater(dates) {
	let dateObj = {};
	let date = new Date(dates);
	date.setDate(date.getDate());
	let yearDate = date.getFullYear();
	let month = ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth() + 1);
	dateObj = yearDate + '年' + month + '月';
	return dateObj;
}

function getToDay(date) {
	const year = date.getFullYear();
	const month = date.getMonth() + 1;
	const day = date.getDate();

	let today = year + '年' + month + '月' + day + '日';
	return today;
}

function getFullDate(date) {
	const newDate = new Date(date);
	console.log(newDate)
	const year = newDate.getFullYear();
	const month = newDate.getMonth() + 1;
	const day = newDate.getDate();

	let fullDate = [year + '年', month + '月', day + '日'];
	return fullDate;
}

function toDate(dates){
	dates = dates.replace("年","-");
	if(dates.indexOf("日") != -1){
		dates = dates.replace("月","-");
		dates = dates.replace("日","");
	}else{
		dates = dates.replace("月","");
	}
	return dates;
}

export default {
	formatDate,
	toDate,
	getToDay,
	getFullDate
}